﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Go.Tools
{
    //interface that all observable classes should implement
    public abstract class IObservable
    {
        protected List<IObserver> _observerContainer = new List<IObserver>();

        public void Register(IObserver anObserver)
        {
            _observerContainer.Add(anObserver);
        }

        public void UnRegister(IObserver anObserver) {
            _observerContainer.Remove(anObserver);
        }

        //common method to notify all the observers
        public void NotifyObservers(object anObject)
        {

            foreach (IObserver anObserver in _observerContainer)
            {
                anObserver.Update(anObject);
            }//foreach

        }//NotifyObservers

    }//IObservable
}
